% corr2d.m
% created 02/04/2012
% Crown copyright
%
% Description: Returns correltation coefficient between two matrices
%
% @author Kevin O'Holleran <kevin.o-holleran@npl.co.uk>
%
% @param A - matrix
% @param B - matrix
%
% @return result - double
function [ result ] = corr2d(A,B)

n = (A - mean(A(:))).*(B - mean(B(:)));

d1 = (A - mean(A(:))).^2;
d2 = (B - mean(B(:))).^2;

result = sum(n(:))/sqrt(sum(d1(:))*sum(d2(:)));

end

